package guijavacommander.actions;

import guijavacommander.FilePanel;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * User: Deady
 * Date: 16.07.2009
 * Time: 16:23:51
 */
public class EditFileAction extends AbstractAction {

    private FilePanel panel;
    Log logger = LogFactory.getLog(EditFileAction.class);

    public EditFileAction(FilePanel panel) {
        this.panel = panel;
    }

    public void actionPerformed(ActionEvent e) {
        logger.debug("edit file");
        File f = panel.getCurrentFile();
        try {
            Runtime.getRuntime().exec("geany "+f.getAbsolutePath());
        } catch (IOException e1) {
            e1.printStackTrace();
            JOptionPane.showMessageDialog(panel, "Can't edit file "+f, "Error", JOptionPane.ERROR_MESSAGE);
        }

    }


}
